//
//  HttpManager.swift
//  AnShiPai
//
//  Created by 马瑜 on 2017/7/6.
//  Copyright © 2017年 马瑜. All rights reserved.
//

import UIKit
import Foundation
import Moya
import ReactiveMoya
import RxMoya

enum HttpManager {
    case login(loginName: String, password: String)
    case register(userMobile: String, password: String, inviteCode: String, verifyCode: String)
    
}


extension HttpManager: TargetType {
    /// The parameters to be encoded in the request.
    public var parameters: [String : Any]? {
        switch self {
        case let .login(loginName: loginName, password: password):
            return ["loginName": loginName as AnyObject, "userPassword": password as AnyObject]
        default :
            return nil
        }
    }


    var baseURL: URL {
        return URL.init(string: SERVICE_ADDRESS)!
    }
    
    /// The path to be appended to `baseURL` to form the full `URL`.
    var path: String {
        switch self {
        case .login(loginName: _, password: _):
            return "aaaaa"
        case .register(userMobile: _, password: _, inviteCode: _, verifyCode: _):
            return "bbbb"
        }
        
    }
    
    /// The HTTP method used in the request.
    var method: Moya.Method {
        return .post
    }
    
    
    /// The method used for parameter encoding.
    var parameterEncoding: ParameterEncoding {
        return URLEncoding.default
    }
    
    /// Provides stub data for use in testing.
    var sampleData: Data {
        return "".data(using: String.Encoding.utf8)!
    }
    
    /// The type of HTTP task to be performed.
    var task: Task {
        return .request
    }
    
    /// Whether or not to perform Alamofire validation. Defaults to `false`.
    var validate: Bool {
        return false
    }
    

    
}
